/**
 * 库存相关路由
 */
const express = require('express');
const router = express.Router();
const inventoryController = require('../controllers/inventoryController');
const { authenticate, authorize } = require('../middlewares/auth');

// 获取库存概览
router.get('/overview', authenticate, inventoryController.getInventoryOverview);

// 调整库存
router.post('/adjust', authenticate, authorize(['admin', 'manager']), inventoryController.adjustInventory);

// 获取库存状态报表
router.get('/reports/status', authenticate, inventoryController.getInventoryStatusReport);

// 仓库管理相关路由
router.get('/warehouses', authenticate, inventoryController.getAllWarehouses);
router.get('/warehouses/:id', authenticate, inventoryController.getWarehouseById);
router.post('/warehouses', authenticate, authorize(['admin', 'manager']), inventoryController.createWarehouse);
router.put('/warehouses/:id', authenticate, authorize(['admin', 'manager']), inventoryController.updateWarehouse);
router.delete('/warehouses/:id', authenticate, authorize(['admin']), inventoryController.deleteWarehouse);

// 供应商管理相关路由
router.get('/suppliers', authenticate, inventoryController.getAllSuppliers);
router.get('/suppliers/:id', authenticate, inventoryController.getSupplierById);
router.post('/suppliers', authenticate, authorize(['admin', 'manager']), inventoryController.createSupplier);
router.put('/suppliers/:id', authenticate, authorize(['admin', 'manager']), inventoryController.updateSupplier);
router.delete('/suppliers/:id', authenticate, authorize(['admin']), inventoryController.deleteSupplier);

// 单个商品库存管理
router.get('/product/:id', authenticate, inventoryController.getProductInventory);
router.put('/product/:id', authenticate, authorize(['admin', 'manager']), inventoryController.updateProductInventory);

module.exports = router; 